//用于创建一个为count组件服务的reducer
//reducer函数会接到两个参数：之前的状态 preState,动作对象action

const startValue = 0
export default function countReducer(preState = startValue, action) {
    //从action中获取type,data
    const { type, data } = action
    switch (type) {
        case 'increment': //加
            return preState + data
        default:
            return startValue
    }
}